/**
 * Created by kule on 2017/5/22.
 */
export const getFitSize = function (origin,target) {
    const {width,height}=origin;
    const radio=getRatio(origin,target);

    return {
        radio,
        width:width*radio,
        height:height*radio,
    };
};
export const getRatio=(origin,target={})=>{
    const {width,height}=origin;
    const tWidth=target.width;
    const tHeight=target.height;

    if(tWidth&&!tHeight){
        return tWidth/width;
    }
    if(!tWidth&&tHeight){
        return tHeight/height;
    }
    if(tWidth&&tHeight){
        return Math.min(tWidth/width,tHeight/height);
    }
    return 1;
};
export default getFitSize;